# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# GNU Makefile based on shared rules provided by the Native Client SDK.
# See README.Makefiles for more details.

VALID_TOOLCHAINS := pnacl newlib clang-newlib

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../..)

TARGET = media_player


include $(NACL_SDK_ROOT)/tools/common.mk

INC_PATHS += ../../common/src \
	../../common/src/utils \
	../../common/src/decoder \
	../../common/lib/ffmpeg/payload/include \
	../../common/lib/libwebsockets/payload/include \
	../../common/lib/openssl/payload/include \
	../../common/keys


LIB_PATHS += lib/ffmpeg/payload/lib \

CHROME_ARGS += --allow-nacl-socket-api=localhost 

DEPS = nacl_io
LIBS = nacl_io ppapi_gles2 ppapi_cpp ppapi pthread

CFLAGS = -Wall -Wno-deprecated-declarations -Wno-self-assign -DUSE_SW_DEC -DDEMO_LOGO
SOURCES = ../../common/src/media_player.cc \
	../../common/src/utils/utils.c \
	../../common/src/player.c \
	../../common/src/texture.cc \
	../../common/src/mp_video_render.cc \
	../../common/src/mp_audio_render.cc \
	../../common/src/mp_data_source.cc \
	../../common/src/decoder/ffmpeg_audio_decoder_provider.c \
	../../common/src/decoder/ff_video_decoder.c \
	../../common/src/mp_websc.cc \
	../../common/src/win_cs.c  \
	../../common/src/mp_writer.cc

#LDFLAGS += -L../../common/lib/ffmpeg/payload/lib/pnacl -lavformat -lavfilter -lavcodec -lswscale -lavutil -lswresample \
	#-Llib/lame/payload/lib -lmp3lame \
	#-Llib/libtheora/payload/lib -ltheora \
	#-Llib/libvorbis/payload/lib -lvorbis -lvorbisenc \
	#-Llib/libogg/payload/lib -logg \

LDFLAGS += -L../../common/lib/ffmpegmp2/payload/lib/pnacl -lavformat -lavcodec -lavutil -lswscale -lswresample -lavfilter

# Build rules generated by macros from common.mk:

$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

# The PNaCl workflow uses both an unstripped and finalized/stripped binary.
# On NaCl, only produce a stripped binary for Release configs (not Debug).
ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG))))
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif

$(eval $(call NMF_RULE,$(TARGET),))

